<template>
<!--  <div class="table">-->
<!--    暂未实现-->
<!--    <el-table-->
<!--          :data="tableData"-->
<!--          style="width: 100%">-->
<!--          <el-table-column-->
<!--            type="index"-->
<!--            prop="id"-->
<!--            label="序号"-->
<!--            width="135px"-->
<!--            :show-overflow-tooltip="true">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="userName"-->
<!--            label="姓名">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="addTime"-->
<!--            label="性别"-->
<!--            :show-overflow-tooltip="true">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="affiliatedCampus"-->
<!--            label="所属校区"-->
<!--            :show-overflow-tooltip="true">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="phoneNum"-->
<!--            label="手机号码"-->
<!--            :show-overflow-tooltip="true">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="addTime"-->
<!--            label="添加时间"-->
<!--            :show-overflow-tooltip="true">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            label="操作"-->
<!--            width="180px">-->
<!--            <template slot-scope="scope">-->
<!--              <el-button size="small" @click="showModifyModel(scope.row.id)">修 改</el-button>-->
<!--              <el-button size="small" type="danger" @click="showDelModel(scope.row.id)">删 除</el-button>-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--        </el-table>-->
<!--  </div>-->
  <el-dialog
    title="物业人员管理"
    top="125px"
    :visible.sync="managePropertyPersonnel"
    :before-close="closeAllModel"
    :close-on-click-modal="false"
    :close-on-press-escape="false">
    <hr class="boundary">
    <el-table
      :data="tableData"
      height="270px"
      style="width: 90%">
      <el-table-column
        prop="id"
        label="工号"
        :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="添加时间">
      </el-table-column>
      <el-table-column
        prop="id"
        label="操作"
        width="180px">
        <template slot-scope="scope">
          <el-button size="mini" @click="showModifyModel(scope.row.id)">管 理</el-button>
          <el-button type="danger" size="mini" @click="showDelModel(scope.row.id)">删 除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <hr class="boundary">
    <add-user :updateData="updateData" :addUser="addUser" @closeModel="closeModel"></add-user>
    <modify-user :modifyId="modifyId" :modifyUser="modifyUser" @closeModel="closeModel"></modify-user>
    <del-user :delId="delId" :delUser="delUser" @closeModel="closeModel"></del-user>
    <div slot="footer" class="dialog-footer">
      <el-button type="success" @click="showAddModel">添加</el-button>
      <el-button size="small" @click="closeAllModel">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import addUser from './propertyUser/addUser'
  import modifyUser from './propertyUser/modifyUser'
  import delUser from './propertyUser/delUser'

  export default {
    components: {
      addUser,
      modifyUser,
      delUser
    },
    props: {
      managePropertyPersonnel: Boolean
    },
    data () {
      return {
        addUser: false,
        modifyId: '',
        modifyUser: false,
        delId: '',
        delUser: false,
        tableData: [],
        updateData: false
      }
    },
    methods: {
      showAddModel () {
        this.addUser = true
        this.updateData = true
      },

      showModifyModel (id) {
        this.modifyId = id
        this.modifyUser = true
      },

      showDelModel (id) {
        this.delId = id
        this.delUser = true
      },

      closeModel () {
        this.addUser = false
        this.modifyId = ''
        this.modifyUser = false
        this.delId = ''
        this.delUser = false
        this.updateData = false
        this.getList()
      },
      closeAllModel(){
        this.$emit('closeModel')
      },
      getList () {
        let self = this
        $.ajax({
          type: 'GET',
          url: this.api + 'propertyUser',
          headers: {
            'X-Requested-With': 'XMLHttpRequest'
          },
          xhrFields: {
            withCredentials: true
          },
          success (data) {
            for (let i = 0; i < data.length; i++) {
              data[i].create_time = data[i].create_time.split(' ')[0]
            }
            self.tableData = data
            console.log('data:'+self.tableData)
          }
        })
      }
    },
    mounted() {
      this.getList()
    }
  }
</script>

<style scoped>
  @import '../../assets/public/model.css';

  .el-dialog__wrapper >>> .el-dialog {
    width: 655px;
  }

  .el-table--fit {
    margin: 10px auto;
    border: 1px solid #BBBBBB;
  }

  .el-dialog__wrapper >>> .el-table th.is-leaf {
    text-align: center;
    font-size: 16px;
    padding: 7px;
    border-bottom: 1px solid #BBBBBB;
  }

  .el-dialog__wrapper >>> .el-table td {
    text-align: center;
    font-size: 16px;
    padding: 7px 0;
    border-bottom: 1px solid #BBBBBB;
    word-break: keep-all;
    white-space: nowrap;
  }

  .el-button--success {
    float: left;
  }

  .el-dialog__footer .el-button--default, .el-button--success {
    margin: 0;
    border-radius: 8px;
    font-size: 15px;
    padding: 10px 26px;
  }
</style>
